package com.ck.client.controller;

import com.ck.client.service.SysConfigService;
import com.ck.common.model.OperationResult;
import com.ck.core.constant.SysConfigNameEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 应用启动
 *
 * @author hebo
 */
@RestController
@RequestMapping("/appstart")
public class AppStartController {

    @Autowired
    private SysConfigService sysConfigService;

    /**
     * 获取配置信息
     *
     * @return
     */
    @PostMapping(value = "/getConfig")
    public Object getConfig(HttpServletRequest request) {
        Map<String,Object> config = new HashMap<>();

        // 游戏地址
        config.put("gameUrl",sysConfigService.getByType(SysConfigNameEnum.GAME_URL));
        // 货架地址
        config.put("goodsShelves",sysConfigService.getByType(SysConfigNameEnum.GOODS_SHELVES) );
        OperationResult result =  OperationResult.newSuccessOperationResult();
        result.setData(config);
        return result;
    }
}
